﻿using System;
using System.Text;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using BussinessLib;
using System.Data;

/// <summary>
/// Subscribe 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Subscribe : System.Web.Services.WebService {

    public Subscribe () {

        //如果使用设计的组件，请取消注释以下行 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string HelloWorld() {
        return "Hello World";
    }

    [WebMethod]
    public string Order()
    {
        return "HelloWorld";
    }

    [WebMethod]
    public string AddDiscountOrder(string arrive,string tableNum,string resID,string memo,string UID)
    {
        StringBuilder sb = new StringBuilder();
        sb.Append("insert into OrderRecord (ord_dtBookTime,ord_dtArrivalTime,ord_nTableNum,ord_nState,ord_sDesc,ord_nUserID) values(");
        sb.Append("'" + DateTime.Now.ToString() + "','" + arrive+ "'," + tableNum + "," + resID + ",'" + memo + "'," + UID + ");");//tableID为餐馆号

        Helper hp = new Helper();

        if (hp.ExecuteSql(sb.ToString()))
            return "插入成功";
        else
            return "数据库连接失败！";
    }


    [WebMethod]
    public int GetOrderNum(DateTime day,int resID)
    {
        StringBuilder sb = new StringBuilder("select * from orderRecord where  datediff('d','"+day.ToString()+"',ord_dtArrivalTime)=0 and ord_nState="+resID);
        Helper hp = new Helper();

        DataTable t = hp.ExecuteDataTable(sb.ToString());

        return t.Rows.Count;
    }

    [WebMethod]
    public int GetUserLevel(int uid)
    {
        UserInfo.CUser u = new UserInfo.CUser();
        return u.getMemLevel(uid.ToString());
        //if (t.Rows.Count!=0)
        //{
        //    if (t.Rows.Count != 0)
        //        Level = (int)t.Rows[0][12];
        //}


       
    }

   
}

